package i7bac.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public abstract class View extends JPanel {

	private final Color BACKGROUND_COLOR = Color.white;
	private final Font TITLE_FONT = new Font("Calibri", Font.BOLD, 96);
	private View PREVIOUS_VIEW = null;
	private View NEXT_VIEW = null;

	/*
	 * Basic constructor
	 */
	protected View(View previousView, View nextView) {
		super(new BorderLayout(), true);
		setBackground(BACKGROUND_COLOR);
		PREVIOUS_VIEW = previousView;
		NEXT_VIEW = nextView;
	}

	/*
	 * Constructor
	 */
	protected View(String title, JButton okButton, JButton backButton) {
		super(new BorderLayout(), true);
		setBackground(BACKGROUND_COLOR);
		setTitle(title);
		addControllerButtons(okButton, backButton);
	}

	/*
	 * 
	 */
	private void setTitle(String title) {
		JLabel titleLabel = new JLabel(title, JLabel.LEFT);
		titleLabel.setFont(TITLE_FONT);
		add(titleLabel, BorderLayout.NORTH);
	}
	
	private void addControllerButtons(JButton okButton, JButton backButton) {
		JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT), true);
		buttonsPanel.setBackground(null);
		buttonsPanel.add(backButton);
		buttonsPanel.add(okButton);
		add(buttonsPanel, BorderLayout.SOUTH);
	}

}
